﻿using System;
using System.Collections.Generic;
using VI.Fsc.OperatorGui.Models.Application.Util;
using VI.Fsc.OperatorGui.WebReferences.Opc;

namespace VI.Fsc.OperatorGui.Models.Fsc
{
    public class SystemState
    {
        private const string MODE = "Mode";
        private const string PSTATE = "PState";

        private readonly Scope scope;

        public SystemState(Scope scope)
        {
            this.scope = scope;
        }

        public SubscribeRequestItemList GetSubscribeRequestItemList()
        {
            List<SubscribeRequestItem> tempList = new List<SubscribeRequestItem>();
            SubscribeRequestItemList list = new SubscribeRequestItemList();
            tempList.Add(CFscUtility.CreateNewSubscribeRequestItem(scope.GetFullItemPath(PSTATE)));
            tempList.Add(CFscUtility.CreateNewSubscribeRequestItem(scope.GetFullItemPath(MODE)));
            list.Items = tempList.ToArray();

            return list;
        }

        public SorterMode GetMode()
        {
            ItemValue itemValue = CFscUtility.ReadItem(scope.GetFullItemPath(MODE));
            return (SorterMode) Enum.Parse(typeof (SorterMode), (string) itemValue.Value);
        }
    }
}